/**
 * 
 */
package com.shengruan.admin.util;

import com.shengruan.admin.jdbc.SystemEmailJdbc;
import com.shengruan.admin.vo.SystemEmail;
import com.shengruan.common.Mail;

/**
 * @author liubin
 *
 */
public class MessageUtil {

	/**
	 * 发送短信
	 * @param mobile
	 * @param message
	 * @return
	 */
	public static boolean sendSMS(String mobile,String message)
	{
		try
		{
			String cmd = "/usr/JavaSms-linux/jdk/bin/java -classpath /usr/JavaSms-linux/ SendMessage "+mobile+" "+message+"";
			Process process = Runtime.getRuntime().exec(cmd);
			process.waitFor();
			process.destroy();
		}
		catch(Exception e)
		{
			return false;
		}
		return true;
	}
	
	/***
	 * 发送邮件
	 * @param email
	 * @param message
	 * @return
	 */
	public static boolean sendEmail(String email,String title,String content)
	{
		SystemEmailJdbc systemEmailJdbc = new SystemEmailJdbc();
		SystemEmail systemEmail = systemEmailJdbc.getSystemEmail();
		Mail sendmail = new Mail();
		sendmail.setHost(systemEmail.getServer());
		sendmail.setUserName(systemEmail.getUserName());
		sendmail.setPassWord(systemEmail.getPassword());
		sendmail.setFrom(systemEmail.getUserName());
		sendmail.setTo(email);
		sendmail.setSubject(title);
		sendmail.setContent(content); 
		return sendmail.sendMail();
	}
}
